<template>
  <view class="recommend-area">
    <view class="recommend-title">
      <text>精选推荐</text>
    </view>
    <view class="recommend-list">
      <view class="recommend-item" v-for="(item, idx) in recommendList" :key="idx">
        <image :src="item.logo" class="recommend-img" mode="aspectFill" />
        <view class="group-tag">{{ item.groupSize }}人团</view>
        <view class="recommend-info">
          <view class="recommend-name">{{ item.name }}</view>
          <view class="recommend-sold">已拼{{ item.soldCount }}件</view>
          <view class="recommend-price">¥{{ item.price }}</view>
          <view class="user-avatars">
            <image v-for="(avatar, i) in item.avatars" :key="i" :src="avatar" class="avatar-img" />
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import {useData} from "../../../common/useData";
const {modelData:recommendList} = useData("/product/list", {size:20});
</script>

<style scoped>
.recommend-area {
  width: 100%;
  background-color: #ffffff;
  margin-top: 20rpx;
  box-sizing: border-box;
  padding-bottom: 20rpx;
}

.recommend-title {
  font-weight: bold;
  font-size: 36rpx;
  margin-bottom: 20rpx;
}

.recommend-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 20rpx;
}

.recommend-item {
  width: 100%;
  height: 240rpx;
  display: flex;
  position: relative;
  background-color: #fff;
  border-radius: 12rpx;
  box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
  overflow: hidden;
  padding-bottom: 20rpx;
}

.recommend-img {
  width: 240rpx;
  height: 240rpx;
  object-fit: cover;
}

.group-tag {
  position: absolute;
  top: 20rpx;
  left: 0;
  background-color: #ff6a3c;
  color: #fff;
  font-size: 24rpx;
  padding: 6rpx 12rpx;
  border-radius: 0 8rpx 8rpx 0;
}

.recommend-info {
  flex: 1;
  padding: 20rpx;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.recommend-name {
  font-size: 32rpx;
  font-weight: 500;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.recommend-sold {
  font-size: 26rpx;
  color: #999;
  margin-top: 10rpx;
}

.recommend-price {
  font-size: 36rpx;
  color: #ff6a3c;
  font-weight: bold;
  margin-top: 10rpx;
}

.user-avatars {
  position: absolute;
  right: 20rpx;
  bottom: 20rpx;
  display: flex;
}

.avatar-img {
  width: 50rpx;
  height: 50rpx;
  border-radius: 50%;
  border: 2rpx solid #fff;
  margin-left: -10rpx;
}

.avatar-img:first-child {
  margin-left: 0;
}
</style> 